home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS02.ADF / Emacs / ansi.c < prev    next >
C/C++ Source or Header  |  1989-05-30  |  2KB  |  109 lines

  1. /* ansi.c */
  2.  
  3. /*
  4.  * The routines in this file provide support for ANSI style terminals
  5.  * over a serial line. The serial I/O services are provided by routines in
  6.  * "termio.c". It compiles into nothing if not an ANSI device.
  7.  */
  8.  
  9. #include        <stdio.h>
  10. #include        "ed.h"
  11.  
  12. #if     ANSI
  13.  
  14. #define NROW    23                      /* Screen size.                 */
  15. #define NCOL    77                      /* Edit if you want to.         */
  16. #define BEL     0x07                    /* BEL character.               */
  17. #define ESC     0x1B                    /* ESC character.               */
  18.  
  19. extern  int     ttopen();               /* Forward references.          */
  20. extern  int     ttgetc();
  21. extern  int     ttputc();
  22. extern  int     ttflush();
  23. extern  int     ttclose();
  24. extern  int     ansimove();
  25. extern  int     ansieeol();
  26. extern  int     ansieeop();
  27. extern  int     ansibeep();
  28. extern  int     ansiopen();
  29.  
  30. /*
  31.  * Standard terminal interface dispatch table. Most of the fields point into
  32.  * "termio" code.
  33.  */
  34. TERM    term    = {
  35.         NROW-1,
  36.         NCOL,
  37.         &ansiopen,
  38.         &ttclose,
  39.         &ttgetc,
  40.         &ttputc,
  41.         &ttflush,
  42.         &ansimove,
  43.         &ansieeol,
  44.         &ansieeop,
  45.         &ansibeep
  46. };
  47.  
  48. ansimove(row, col)
  49. {
  50.         ttputc(ESC);
  51.         ttputc('[');
  52.         ansiparm(row+1);
  53.         ttputc(';');
  54.         ansiparm(col+1);
  55.         ttputc('H');
  56. }
  57.  
  58. ansieeol()
  59. {
  60.         ttputc(ESC);
  61.         ttputc('[');
  62.         ttputc('K');
  63. }
  64.  
  65. ansieeop()
  66. {
  67.         ttputc(ESC);
  68.         ttputc('[');
  69.         ttputc('J');
  70. }
  71.  
  72. ansibeep()
  73. {
  74.         ttputc(BEL);
  75.         ttflush();
  76. }
  77.  
  78. ansiparm(n)
  79. register int    n;
  80. {
  81.         register int    q;
  82.  
  83.         q = n/10;
  84.         if (q != 0)
  85.                 ansiparm(q);
  86.         ttputc((n%10) + '0');
  87. }
  88.  
  89. #endif
  90.  
  91. ansiopen()
  92. {
  93. #if     V7
  94.         register char *cp;
  95.         char *getenv();
  96.  
  97.         if ((cp = getenv("TERM")) == NULL) {
  98.                 puts("Shell variable TERM not defined!");
  99.                 exit(1);
  100.         }
  101.         if (strcmp(cp, "vt100") != 0) {
  102.                 puts("Terminal type not 'vt100'!");
  103.                 exit(1);
  104.         }
  105. #endif
  106.         ttopen();
  107. }
  108.  
  109.